home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / scanline_draw_II.s < prev    next >
Text File  |  1999-04-15  |  14KB  |  578 lines

  1.  
  2. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3. ;        scanline drawer
  4. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5.  
  6. scanline_draw:    tst.b    old_render            ;aga mode?
  7.         beq.w    scanline_aga            ;yes.
  8.  
  9.         move.b    output_bit,d7
  10.         cmp.b    frame_update,d7
  11.         bne.w    no_scan_draw            ;no draw.
  12.  
  13.         cmp.l    #144,gb_scanlines        ;drawing time?
  14.         bge.w    no_scan_draw            ;no!
  15.  
  16.         move.l    gb_memory,a6            ;a6 = the fixed 16bit
  17.         add.l    #$ff40,a6            ;a6 = lcd control.
  18.         moveq.l    #0,d6
  19.         move.b    (a6),d6                ;d6 = lcd control byte.
  20.         btst    #7,d6                ;lcd operation?
  21.         beq.w    no_scan_draw            ;no. quit.
  22.         move.l    d6,lcd_control            ;store the byte.
  23.  
  24.         bsr.w    push_z80
  25.  
  26.         bsr.w    scan_draw_bg            ;to the background.
  27.  
  28.         move.l    aga_sprs_inactive,a1
  29.         move.l    gb_scanlines,d0
  30.         tst.b    (a1,d0.l)            ;any old sprites here?
  31.         beq.s    no_scn_spr_clr            ;nope.
  32.  
  33.         move.l    bitmap_spc,a0            ;the sprite area.
  34.         move.l    d0,d1
  35.         lsl.w    #4,d0
  36.         lsl.w    #2,d1
  37.         add.l    d1,d0                ;d0 = d0 * 20.
  38.         add.l    d0,a0
  39.         lea    2880(a0),a1
  40. ;        moveq.l    #160/32-1,d0
  41.         moveq.l    #0,d3
  42.         move.l    d3,(a0)+
  43.         move.l    d3,(a1)+
  44.         move.l    d3,(a0)+
  45.         move.l    d3,(a1)+
  46.         move.l    d3,(a0)+
  47.         move.l    d3,(a1)+
  48.         move.l    d3,(a0)+
  49.         move.l    d3,(a1)+
  50.         move.l    d3,(a0)
  51.         move.l    d3,(a1)
  52.  
  53. no_scn_spr_clr:    bsr.w    scan_window
  54.         clr.l    aga_spr_amount            ;zero done on this scanline.
  55.         bsr.w    scan_sprites            ;do them!
  56.         move.l    aga_sprs_inactive,a0
  57.         add.l    gb_scanlines,a0
  58.         move.b    aga_spr_amount,(a0)
  59.  
  60.         cmp.l    #143,gb_scanlines        ;time to update the palette
  61.         bne.s    no_scan_draw_x            ;and draw the view?
  62.  
  63.         bsr.w    update_bg_pal            ;yes. do palette.
  64.         bsr.w    screen_draw_pl            ;yes. do screen.
  65.         bsr.w    swap_lists_nor
  66.  
  67. no_scan_draw_x:    bsr.w    pull_z80
  68. no_scan_draw:    rts                    ;exit.
  69.  
  70. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  71. ;        execute the background copying
  72. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  73.  
  74. scan_draw_bg:    move.l    d6,d0                ;d0 = lcd control byte.
  75.         btst    #0,d0                ;background display?
  76.         beq.w    scan_draw_bgy            ;no. quit.
  77.  
  78.         move.l    gb_memory,a0            ;a0 = the fixed 16bit
  79.         move.l    a0,a1                ;memory area.
  80.         add.l    #$ff42,a1
  81.         moveq.l    #0,d2
  82.         move.b    (a1)+,d2            ;d2 = bg scroll y.
  83.         moveq.l    #0,d3
  84.         move.b    (a1),d3                ;d3 = bg scroll x.
  85.  
  86.         move.l    d0,d1                ;d1 = the control byte.
  87.         and.b    #%1000,d0            ;d0 = background tiles.
  88.         lsl.w    #7,d0                ;0/1 * 1024.
  89.         move.l    a0,a1
  90.         add.l    #$9800,a1            ;tile position.
  91.         add.l    d0,a1                ;selected position.
  92.                             ;a1 = input tiles.
  93.         moveq.l    #0,d7
  94.         and.b    #%10000,d1            ;d1 = background tile
  95.         move.b    d1,d7                ;datas. 0/1 * 2048.
  96.         lsl.b    #3,d7                ;d7 = tile adder (signed/
  97.         bchg    #7,d7                ;unsigned).
  98.         move.l    d7,tile_adder
  99.         lsl.w    #7,d1
  100.         move.l    a0,a2
  101.         add.l    #$8800,a2            ;tile data position.
  102.         sub.l    d1,a2                ;selected position.
  103.                             ;a2 = input tile datas.
  104.         move.l    a2,gb_tiles
  105.  
  106. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  107. ;        copy background data
  108. ;        INPUT:
  109. ;        d2    = background scroll y.
  110. ;        d3    = background scroll x.
  111. ;        a1    = tiles.
  112. ;        a2    = tile datas.
  113. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  114.  
  115.         move.l    gb_scanlines,d7
  116.         add.l    d7,d2                ;y = y start + y position.
  117.         move.b    d2,d4
  118.         lsr.w    #3,d2                ;d2 = number of rows
  119.                             ;to be skipped.
  120.         and.l    #%11111,d2            ;stay inside the range.
  121.  
  122.         lsl.w    #5,d2                ;d2 = d2 * 32 (start y).
  123.         add.l    d2,a1                ;y of tiles = done.
  124.  
  125.         move.b    d3,d5
  126.         lsr.w    #3,d3                ;d3 = x start.
  127.         and.l    #%11111,d3            ;stay inside the range.
  128.  
  129.         and.l    #%111,d5            ;d5 = x pixel scroll (0-7).
  130.         and.l    #%111,d4            ;d4 = y pixel scroll (0-7).
  131.         move.b    d5,d0
  132.         swap    d5
  133.         move.b    #8,d5
  134.         sub.b    d0,d5
  135.         swap    d5
  136.  
  137. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  138. ;        copy 160x1
  139. ;        INPUT:
  140. ;        d3    = (background start x) / 8.
  141. ;        d4    = background scroll y.
  142. ;        d5    = background scroll x (.W right, .W left).
  143. ;        d7    = gb_scanlines.
  144. ;        a1    = tiles.
  145. ;        a2    = tile datas.
  146. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  147.  
  148.         move.l    bitmap_bg,a0            ;bitmap (output p0).
  149.         move.l    d7,d1
  150.         lsl.w    #4,d7
  151.         lsl.w    #2,d1
  152.         add.w    d1,d7                ;d7 = d7 * 20.
  153.  
  154.         add.l    d7,a0                ;y position fix.
  155.         lea    2880(a0),a3            ;bitmap (output p1).
  156.  
  157.         lsl.b    #1,d4                ;d4 = d4 * 2.
  158.         add.l    d4,a2                ;y position added.
  159.  
  160. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  161. ;        copy 160x1 area
  162. ;        INPUT:
  163. ;        d3    = (background start x) / 8 (=<31).
  164. ;        d5    = background scroll x (.W right, .W left).
  165. ;        a0    = bitmap (output p0).
  166. ;        a1    = tiles.
  167. ;        a2    = tile datas.
  168. ;        a3    = bitmap (output p1).
  169. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  170.  
  171.         moveq.l    #160/8/4-1,d0
  172.         move.l    tile_adder,d7
  173.         move.l    d7,a6
  174.  
  175. load_scn_data:    move.l    a6,d1
  176.         add.b    (a1,d3.l),d1
  177.         addq.b    #1,d3
  178.         lsl.w    #4,d1
  179.         and.b    #$1f,d3
  180.         move.w    (a2,d1.l),d2
  181.  
  182.         move.l    a6,d1
  183.         add.b    (a1,d3.l),d1
  184.         addq.b    #1,d3
  185.         lsl.w    #4,d1
  186.         and.b    #$1f,d3
  187.         move.w    (a2,d1.l),d4
  188.  
  189.         move.l    a6,d1
  190.         add.b    (a1,d3.l),d1
  191.         addq.b    #1,d3
  192.         lsl.w    #4,d1
  193.         and.b    #$1f,d3
  194.         move.w    (a2,d1.l),d6
  195.  
  196.         move.l    a6,d1
  197.         add.b    (a1,d3.l),d1
  198.         addq.b    #1,d3
  199.         lsl.w    #4,d1
  200.         and.b    #$1f,d3
  201.         move.w    (a2,d1.l),d7
  202.  
  203.         move.b    d2,d1
  204.         lsl.w    #8,d1
  205.         move.b    d4,d1
  206.         lsl.l    #8,d1
  207.         move.b    d6,d1
  208.         lsl.l    #8,d1
  209.         move.b    d7,d1                ;d1 = l.B, lm.B, rm.B, r.B.
  210.                             ;     (p1).
  211.         lsr.w    #8,d4
  212.         move.b    d4,d2
  213.         swap    d2
  214.         move.w    d6,d2
  215.         lsr.w    #8,d7
  216.         move.b    d7,d2                ;d2 = l.B, lm.B, rm.B, r.B.
  217.                             ;     (p0).
  218.         lsl.l    d5,d1
  219.         lsl.l    d5,d2                ;both planes shifted.
  220.  
  221.         move.l    a6,d4
  222.         add.b    (a1,d3.l),d4
  223.         lsl.w    #4,d4
  224.         move.w    (a2,d4.l),d7
  225.         move.b    d7,d6
  226.         swap    d5
  227.         lsr.w    #8,d7
  228.         lsr.b    d5,d6
  229.         lsr.b    d5,d7
  230.         or.b    d6,d1
  231.         or.b    d7,d2
  232.  
  233.         move.l    d1,(a3)+
  234.         swap    d5
  235.         move.l    d2,(a0)+
  236.  
  237.         dbra    d0,load_scn_data
  238.  
  239. scan_draw_bgy:    rts                    ;exit background drawing.
  240.  
  241. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  242. ;        do the sprites
  243. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  244.  
  245. scan_sprites:    move.l    gb_memory,a0
  246.         move.l    a0,a1
  247.         move.l    a0,a2
  248.         add.l    #$fe00+40*4,a0            ;a0 = sprite attribute table.
  249.         add.l    #$8000,a1            ;a1 = sprite pattern table.
  250.         add.l    #$ff48,a2            ;a2 = obj0pal.B, obj1pal.B.
  251.         moveq.l    #40-1,d0            ;d0 = number of sprites.
  252.  
  253. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  254. ;        first fo the sprites beyond the window
  255. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  256.  
  257.         move.l    lcd_control,d1            ;d1 = lcd control byte.
  258.         btst    #1,d1                ;sprites off?
  259.         beq.w    exit_spr            ;yes.
  260.         btst    #2,d1                ;sprite size?
  261.         bne.w    sspr_n8x16            ;8x16.
  262.  
  263. sspr_n8x8:    move.l    #8-1,sprite_y            ;a coming compare fixed
  264.         move.b    #$ff,sprite_mask
  265.         bra.s    sspr_c8xq            ;value.
  266. sspr_n8x16:    move.l    #16-1,sprite_y
  267.         move.b    #$fe,sprite_mask
  268.  
  269. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  270. ;        sprite size 8xq, q=8/16.
  271. ;        INPUT:
  272. ;        d0    = number of sprites.
  273. ;        a0    = sprite attribute table.
  274. ;        a1    = sprite pattern table.
  275. ;        a2    = obj0pal.B, obj1pal.B.
  276. ;        a3    = sprite output planes.
  277. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  278.  
  279. sspr_c8xq:    cmp.b    #10,aga_spr_amount        ;max sprites (h/w limit)?
  280.         beq.w    exit_spr            ;yes.
  281.  
  282.         move.l    -(a0),d1            ;d1 = y.B, x.B, gfx.B, flags.B.
  283.         swap    d1                ;d1 = gfx.B, flags.B, y.B, x.B.
  284.         moveq.l    #0,d2
  285.         moveq.l    #0,d3
  286.         move.b    d1,d2                ;d2 = x.B.
  287.         cmp.w    #160+8,d2            ;crossed the right border?
  288.         bge.w    next_spr            ;yes.
  289.  
  290.         ror.w    #8,d1                ;d1 = gfx.B, flags.B, x.B, y.B.
  291.         move.b    d1,d3                ;d3 = y.B.
  292.  
  293.         move.l    gb_scanlines,d4            ;d4 = the scanline number.
  294.         move.l    d4,d5
  295.         add.l    #16,d4                ;y position fix.
  296.         move.l    d4,d6
  297.         cmp.w    d3,d4                ;scanline lower?
  298.         blt.w    next_spr            ;yes.
  299.         move.l    d3,d7
  300.         add.l    sprite_y,d7
  301.         cmp.w    d7,d4                ;scanline higher?
  302.         bgt.w    next_spr            ;yes.
  303.  
  304.         move.l    d5,d7
  305.         lsl.w    #4,d5
  306.         lsl.w    #2,d7
  307.         add.w    d7,d5                ;d5 = y on screen (d5 * 20).
  308.  
  309.         sub.l    d3,d6                ;d6 = y inside the sprite.
  310.         move.l    bitmap_spc,a4
  311.         move.l    d5,a5                ;a5 = output bg  (p0).
  312.         add.l    d5,a4                ;a4 = output spr (p0).
  313.         add.l    bitmap_bg,a5
  314.  
  315.         rol.l    #8,d1                ;d1 = flags.B, x.B, y.B, gfx.B.
  316.         and.b    sprite_mask,d1
  317.         move.b    d1,d3                ;d3 = gfx.B.
  318.         lsl.w    #4,d3                ;d3 = d3 * 16.
  319.  
  320.         rol.l    #8,d1                ;d1 = x.B, y.B, gfx.B, flags.B.
  321.         btst    #6,d1                ;y flipped?
  322.         bne.w    sspr_c8xq_flip            ;yes.
  323.  
  324. spr_y_back:    lsl.b    #1,d6                ;y = y * 2 (for data).
  325.         moveq.l    #0,d7
  326.         add.l    d6,d3
  327.         move.w    (a1,d3.l),d7            ;d7 = pattern data.
  328.         beq.w    next_spr            ;empty sprite.
  329.  
  330.         addq.b    #1,aga_spr_amount        ;one more.
  331.  
  332.         moveq.l    #0,d3
  333.         move.b    d1,d3
  334.         and.b    #%10000,d3            ;palette bit.
  335.         lsr.b    #4,d3                ;take it down.
  336.         ror.l    #8,d1                ;d1 = flags.B, x.B, y.B, gfx.B.
  337.         move.b    (a2,d3.l),d1            ;d1 = flags.B, x.B, y.B, pal.B.
  338.         rol.l    #8,d1                ;d1 = x.B, y.B, pal.B, flags.B.
  339.  
  340.         btst    #5,d1                ;x flipped?
  341.         bne.w    sspr_c8xq_copyx            ;yes.
  342.  
  343. spr_x_back:    lsr.w    #8,d1                ;d1 = x.B, y.B, 0.B, pal.B.
  344.         cmp.w    #8,d2                ;x < 8?
  345.         blt.s    spr_less_8            ;yes.
  346.         cmp.w    #8+160-8,d2            ;152 < x < 160?
  347.         bgt.w    spr_over_152
  348.  
  349.         subq.l    #8,d2                ;x position fix.
  350.         move.l    d2,d4                ;d4 = x.B.
  351.         lsr.w    #3,d4                ;d4 = x.B / 8.
  352.         add.l    d4,a4                ;y and x fixed.
  353.         add.l    d4,a5                ;y and x fixed.
  354.  
  355.         move.w    d7,d3
  356.         bsr.w    spr_col_change
  357.  
  358.         moveq.l    #0,d7
  359.         move.b    d3,d7                ;d7 = 1.B.
  360.         lsr.w    #8,d3                ;d3 = 0.B.
  361.         moveq.l    #8,d1
  362.         and.b    #%111,d2            ;d2 = bit skip (0-7).
  363.         sub.b    d2,d1
  364.         lsl.w    d1,d7                ;shift data 1.
  365.         lsl.w    d1,d3                ;shift data 0.
  366.         ror.w    #8,d6
  367.         rol.w    d1,d6                ;shift mask.
  368.  
  369.         and.w    d6,(a4)
  370.         or.w    d3,(a4)
  371.         add.l    #160/8*144,a4
  372.         and.w    d6,(a4)
  373.         or.w    d7,(a4)
  374.  
  375.         swap    d5                ;mask down.
  376.         swap    d6                ;adder down.
  377.         ror.w    #8,d5
  378.         ror.w    #8,d6
  379.         rol.w    d1,d5                ;shift mask.
  380.         rol.w    d1,d6                ;shift adder.
  381.         and.w    d5,(a5)
  382.         or.w    d6,(a5)
  383.         add.l    #160/8*144,a5
  384.         and.w    d5,(a5)
  385.         or.w    d6,(a5)
  386.  
  387. next_spr:    dbra    d0,sspr_c8xq            ;next sprite.
  388. exit_spr:    rts
  389.  
  390. spr_less_8:    move.w    d7,d3
  391.         bsr.w    spr_col_change
  392.  
  393.         moveq.l    #8,d1
  394.         and.b    #%111,d2
  395.         sub.b    d2,d1
  396.  
  397.         move.b    d3,d7                ;d7 = 1.B.
  398.         clr.b    d3
  399.         lsl.w    #8,d7
  400.         lsl.w    d1,d7
  401.         lsl.w    d1,d3
  402.         lsl.w    d1,d6                ;shift mask.
  403.         moveq.l    #1,d2
  404.         lsl.b    d1,d2
  405.         subq.b    #1,d2
  406.         or.b    d2,d6
  407.  
  408.         and.w    d6,(a4)
  409.         or.w    d3,(a4)
  410.         add.l    #160/8*144,a4
  411.         and.w    d6,(a4)
  412.         or.w    d7,(a4)
  413.  
  414.         swap    d5                ;mask down.
  415.         swap    d6                ;adder down.
  416.         lsl.w    d1,d5                ;shift mask.
  417.         lsl.w    d1,d6                ;shift adder.
  418.         or.b    d2,d5
  419.         and.w    d5,(a5)
  420.         or.w    d6,(a5)
  421.         add.l    #160/8*144,a5
  422.         and.w    d5,(a5)
  423.         or.w    d6,(a5)
  424.  
  425.         dbra    d0,sspr_c8xq            ;next sprite.
  426.         rts
  427.  
  428. spr_over_152:    add.l    #(160/8)-2,a4
  429.         add.l    #(160/8)-2,a5
  430.  
  431.         move.w    d7,d3
  432.         bsr.w    spr_col_change
  433.  
  434.         and.b    #%111,d2
  435.         moveq.l    #0,d7
  436.         move.b    d3,d7                ;d7 = 1.B.
  437.         lsr.w    #8,d3
  438.         lsr.b    d2,d7
  439.         lsr.b    d2,d3
  440.  
  441.         addq.b    #8,d2
  442.         move.l    #$ffff0000,d1
  443.         move.w    d6,d1
  444.         asr.l    d2,d1
  445.  
  446.         and.w    d1,(a4)
  447.         or.w    d3,(a4)
  448.         add.l    #160/8*144,a4
  449.         and.w    d1,(a4)
  450.         or.w    d7,(a4)
  451.  
  452.         move.w    #$ffff,d5
  453.         swap    d5                ;mask down.
  454.         swap    d6                ;adder down.
  455.         asr.l    d2,d5                ;shift mask.
  456.         lsr.w    d2,d6                ;shift adder.
  457.         and.w    d5,(a5)
  458.         or.w    d6,(a5)
  459.         add.l    #160/8*144,a5
  460.         and.w    d5,(a5)
  461.         or.w    d6,(a5)
  462.  
  463.         dbra    d0,sspr_c8xq            ;next sprite.
  464.         rts
  465.  
  466. sspr_c8xq_copyx:move.l    x_flip_table,a3
  467.         move.w    (a3,d7.l*2),d7            ;fetch the x flipped data.
  468.         bra.w    spr_x_back
  469.  
  470. sspr_c8xq_flip:    move.b    sprite_y+3,d4
  471.         eor.b    d4,d6                ;y flipped.
  472.         bra.w    spr_y_back
  473.  
  474. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  475. ;        draw a scanline of the window
  476. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  477.  
  478. scan_window:    move.l    lcd_control,d3            ;d3 = lcd control byte.
  479.         btst    #5,d3                ;window display?
  480.         beq.w    scan_draw_wxt            ;nope.
  481.         btst    #0,d3
  482.         beq.w    scan_draw_wxt
  483.  
  484.         move.l    gb_memory,a0            ;a0 = the fixed 16bit
  485.         move.l    a0,a2
  486.  
  487.         moveq.l    #0,d0
  488.         add.l    #$ff4a,a2            ;a2 = window y position.
  489.         move.b    (a2)+,d0            ;d0 = window y pos ($ff4A).
  490.         move.l    gb_scanlines,d2            ;d2 = the current scanline.
  491.         cmp.w    d0,d2
  492.         blt.w    scan_draw_wxt            ;window not achieved, yet.
  493.  
  494.         moveq.l    #0,d1
  495.         move.b    (a2),d1                ;d1 = window x pos ($ff4B).
  496.         subq.w    #7,d1                ;x position fix.
  497.         bge.s    win_win_ok
  498.         clr.w    d1
  499. win_win_ok:    cmp.w    #160,d1
  500.         bge.w    scan_draw_wxt            ;right out!
  501.  
  502.         add.l    #$9800,a0            ;window tiles.
  503.         and.b    #%1000000,d3            ;d3 = tile position.
  504.         lsl.w    #4,d3                ;d3 = 0/1 * 1024.
  505.         add.l    d3,a0                ;a0 = window tiles.
  506.  
  507.         move.l    gb_tiles,a1
  508.  
  509. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  510. ;        INPUT:
  511. ;        a0    = window tiles.
  512. ;        a1    = window tile pattern table.
  513. ;        d0    = window y position.
  514. ;        d1    = window x position.
  515. ;        d2    = gb scanline.
  516. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  517.  
  518.         move.l    d2,d3
  519.         sub.l    d0,d2                ;d2 = delta y in window.
  520.         move.l    d2,d6                ;d6 = y in window.
  521.         move.l    d1,d7                ;d7 = window x position.
  522.         lsr.w    #3,d6                ;d6 = y in bytes.
  523.         lsr.w    #3,d7                ;d7 = x in bytes.
  524.         lsl.w    #5,d6                ;d6 = y in gb rows.
  525.  
  526.         add.l    d6,a0                ;rows added.
  527.         move.l    d3,d6
  528.         lsl.w    #4,d3
  529.         lsl.w    #2,d6
  530.         add.w    d6,d3                ;d3 = d3 * (160/8).
  531.         move.l    bitmap_bg,a3
  532.         add.l    d7,d3                ;d3 = x and y.
  533.         add.l    d3,a3                ;a3 = output bg  (p0).
  534.  
  535.         and.l    #%111,d2            ;d2 = scanline adder.
  536.         move.l    #160/8,d3
  537.         lsl.b    #1,d2                ;data size fix.
  538.         sub.b    d7,d3                ;d3 = delta x in bytes.
  539.         ble.s    scan_draw_wxt            ;too little bytes!
  540.         and.l    #%111,d1            ;d1 = x right shifter.
  541.  
  542. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  543. ;        INPUT:
  544. ;        d1    = x pixels to right shifter.
  545. ;        d2    = the scanline adder.
  546. ;        d3    = delta x in bytes.
  547. ;        a0    = window tiles.
  548. ;        a1    = window tile pattern table.
  549. ;        a3    = background plane 0.
  550. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  551.  
  552.         subq.w    #1,d3                ;dbra correction.
  553.         move.w    #$00ff,d6
  554.         ror.w    d1,d6                ;solid mask.
  555.         add.l    d2,a1                ;y inside the block.
  556.         move.l    a3,a4
  557.         add.l    #160/8*144,a4
  558.  
  559. scan_win_solid:    move.l    tile_adder,d0
  560.         add.b    (a0)+,d0
  561.         lsl.w    #4,d0
  562.         move.w    (a1,d0.l),d4            ;d4 = data.
  563.  
  564.         move.b    d4,d5                ;d5 = 1.B.
  565.         and.w    d6,(a3)
  566.         clr.b    d4
  567.         lsl.w    #8,d5
  568.         and.w    d6,(a4)
  569.         lsr.w    d1,d4                ;shift data.
  570.         lsr.w    d1,d5
  571.  
  572.         or.w    d4,(a3)
  573.         addq.l    #1,a3
  574.         or.w    d5,(a4)
  575.         addq.l    #1,a4
  576.         dbra    d3,scan_win_solid        ;next byte.
  577. scan_draw_wxt:    rts
  578.